package com.xmb.wechat.application;

import android.app.Activity;

import com.blankj.utilcode.util.Utils;
import com.xmb.wechat.bean.MyObjectBox;
import com.xmb.wechat.contact.InitContact;

import io.objectbox.BoxStore;

public class WechatStartApplication extends com.nil.crash.utils.CrashApp {
    private        BoxStore               boxStore;
    private static WechatStartApplication instance;

    @Override
    public void onCreate() {
        super.onCreate();
        // do this once, for example in your Application class
        boxStore = MyObjectBox.builder().androidContext(this).build();
        initDB();
        instance = this;
    }

    /**
     * 初始化数据库
     */
    private void initDB() {
        //        InitContact.initDB(boxStore);
        InitContact.initDB_New(boxStore);
    }

    public static BoxStore getBoxStore(Activity act) {
        return ((WechatStartApplication) (act.getApplication())).getBox();
    }

    public static BoxStore getBoxStore() {
        return ((WechatStartApplication) Utils.getApp()).getBox();
    }

    public BoxStore getBox() {
        return boxStore;
    }

    public static WechatStartApplication getInstance() {
        return instance;
    }
}
